[slimtensor] Storage and SharedPtr for CPU owning mode#16548
Merged
Conversation
…inimal support Pull Request resolved: #16382 This diff introduces the foundational c10 core headers for SlimTensor, a lightweight tensor implementation used by torchnative, to cuda backend runtime and further it will be used by all aoti-driven backends like MPS. We add: - DeviceType.h - Device type enum (CPU only for now) - Device.h - Device class representing compute device location - ScalarType.h - Scalar type enum with elementSize() helper (Float only for now) These headers are modeled after PyTorch's c10 but simplified for our needs. The enum values are kept compatible with PyTorch for serialization compatibility. This is the first step in migrating SlimTensor to replace ETensor as the internal tensor representation in CUDA backend. Future diffs will add Storage, SlimTensor class, and additional dtypes/devices incrementally. ghstack-source-id: 332983719 @exported-using-ghexport Differential Revision: [D89747061](https://our.internmc.facebook.com/intern/diff/D89747061/)
Pull Request resolved: #16383 This diff introduces the foundation for tensor storage management in the SlimTensor migration: - util/SharedPtr.h - A lightweight, non-thread-safe shared pointer optimized for single-threaded tensor operations. - core/Storage.h - The MaybeOwningStorage class that manages tensor data memory: - DeviceTraits<CPU> specialization with allocate(), free(), memcpy() using malloc/free - Owning mode for CPU device (CUDA and non-owning mode added later) - Storage type alias as SharedPtr<MaybeOwningStorage> - Move semantics for efficient resource transfer - clone() and copy_() methods for data management ghstack-source-id: 332983720 @exported-using-ghexport Differential Revision: [D89747980](https://our.internmc.facebook.com/intern/diff/D89747980/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16548
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 56 Pending, 1 Unrelated FailureAs of commit fc492d7 with merge base 9ba1b5d ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Gasoonjia
approved these changes
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #16383 by @Gasoonjia
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/74/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/74/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/73/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/74/orig
Differential Revision: D89747980
@diff-train-skip-merge